/* sprite-sheet-menu.vala
 *
 * Copyright (C) 2010, 2011  Richard Talbot-Watkins
 * Copyright (C) 2010, 2011  Dave Jeffery
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Authors:
 *  Richard Talbot-Watkins <richtw1@gmail.com>
 * 	Dave Jeffery <david.richard.jeffery@gmail.com>
 */

using Gtk;

/**
 * The Sprite Sheet Menu for Beeb Spriter.
 *
 * @author Richard Talbot-Watkins <richtw1@gmail.com>
 * @author Dave Jeffery <david.richard.jeffery@gmail.com>
 * @version 2011.0101
 * @since 0.1
 */
public class BeebSpriter.SpriteSheetMenuBar : MenuBar {
	/* Menus */
	public MenuItem file_menu_button;
	public MenuItem background_menu_button;
	public MenuItem tools_menu_button;
	public MenuItem help_menu_button;

	/* File menu items */
	public MenuItem file_new;
	public MenuItem file_open;
	public MenuItem file_save;
	public MenuItem file_save_as;
	public MenuItem file_revert;
	public MenuItem file_export_settings;
	public MenuItem file_export_to_beeb;
	public MenuItem file_close;
	public MenuItem file_quit;

	/* Background menu items */
	public RadioMenuItem background_transparent;
	public RadioMenuItem background_black;
	public RadioMenuItem background_red;
	public RadioMenuItem background_green;
	public RadioMenuItem background_yellow;
	public RadioMenuItem background_blue;
	public RadioMenuItem background_magenta;
	public RadioMenuItem background_cyan;
	public RadioMenuItem background_white;

	/* Tools Menu items */
	public MenuItem tools_previewer;
	public MenuItem tools_palette;

	/* Help menu items */
	public MenuItem help_about;

	/**
	 * Constructor for the sprite sheet menu bar.
	 *
	 * Any window using this class has to pass in its accelerator group so the
	 * MenuBar object can connect keypresses associated with menu items to it.
	 *
	 * @param accelerator_group Accelerator group used by parent window.
	 */
	public SpriteSheetMenuBar (AccelGroup accelerator_group) {
		/* File menu */
		var file_menu = new Menu ();
		file_new = new MenuItem.with_mnemonic (_("_New..."));
		file_open = new MenuItem.with_mnemonic (_("_Open..."));
		file_save = new MenuItem.with_mnemonic (_("_Save"));
		file_save_as = new MenuItem.with_mnemonic (_("_Save As..."));
		file_revert = new MenuItem.with_mnemonic (_("_Revert"));
		file_export_settings = new MenuItem.with_label 
													(_("Export Settings..."));
		file_export_to_beeb = new MenuItem.with_mnemonic 
													(_("_Export to Beeb..."));
		file_close = new MenuItem.with_mnemonic (_("_Close"));
		file_quit = new MenuItem.with_mnemonic (_("_Quit"));

		file_menu.append (file_new);
		file_menu.append (file_open);
		file_menu.append (new SeparatorMenuItem ());
		file_menu.append (file_save);
		file_menu.append (file_save_as);
		file_menu.append (file_revert);
		file_menu.append (new SeparatorMenuItem ());
		file_menu.append (file_export_settings);
		file_menu.append (file_export_to_beeb);
		file_menu.append (new SeparatorMenuItem ());
		file_menu.append (file_close);
		file_menu.append (file_quit);

		file_new.add_accelerator ("activate", 
									accelerator_group,
									Gdk.keyval_from_name ("N"),
									Gdk.ModifierType.CONTROL_MASK,
									AccelFlags.VISIBLE);

		file_open.add_accelerator ("activate", 
									accelerator_group,
									Gdk.keyval_from_name ("O"),
									Gdk.ModifierType.CONTROL_MASK,
									AccelFlags.VISIBLE);

		file_save.add_accelerator ("activate", 
									accelerator_group,
									Gdk.keyval_from_name ("S"),
									Gdk.ModifierType.CONTROL_MASK,
									AccelFlags.VISIBLE);

		file_save_as.add_accelerator ("activate", 
										accelerator_group,
										Gdk.keyval_from_name ("S"),
										Gdk.ModifierType.CONTROL_MASK |
										Gdk.ModifierType.SHIFT_MASK,
										AccelFlags.VISIBLE);

		file_close.add_accelerator ("activate", 
									accelerator_group,
									Gdk.keyval_from_name ("W"),
									Gdk.ModifierType.CONTROL_MASK,
									AccelFlags.VISIBLE);

		file_quit.add_accelerator ("activate", 
									accelerator_group,
									Gdk.keyval_from_name ("Q"),
									Gdk.ModifierType.CONTROL_MASK,
									AccelFlags.VISIBLE);

		file_menu_button = new MenuItem.with_mnemonic (_("_File"));
		file_menu_button.set_submenu (file_menu);
		append (file_menu_button);

		/* Background Menu */
		var background_menu = new Menu ();
		var background_group = new SList<RadioMenuItem> ();

		background_transparent = new RadioMenuItem.with_label(
										background_group, _("Theme Default"));
		background_black = new RadioMenuItem.with_label (
										background_transparent.get_group (),
										 _("Black"));
		background_red = new RadioMenuItem.with_label (
										background_transparent.get_group (), 
										_("Red"));
		background_green = new RadioMenuItem.with_label (
										background_transparent.get_group (), 
										_("Green"));
		background_yellow = new RadioMenuItem.with_label (
										background_transparent.get_group (), 
										_("Yellow"));
		background_blue = new RadioMenuItem.with_label (
										background_transparent.get_group (), 
										_("Blue"));
		background_magenta = new RadioMenuItem.with_label (
										background_transparent.get_group (), 
										_("Magenta"));
		background_cyan = new RadioMenuItem.with_label (
										background_transparent.get_group (), 
										_("Cyan"));
		background_white = new RadioMenuItem.with_label (
										background_transparent.get_group (), 
										_("White"));

		background_menu.append (background_transparent);
		background_menu.append (background_black);
		background_menu.append (background_red);
		background_menu.append (background_green);
		background_menu.append (background_yellow);
		background_menu.append (background_blue);
		background_menu.append (background_magenta);
		background_menu.append (background_cyan);
		background_menu.append (background_white);

		background_menu_button = new MenuItem.with_mnemonic (_("_Background"));
		background_menu_button.set_submenu (background_menu);
		append (background_menu_button);

		/* Tools Menu */
		var tools_menu = new Menu ();
		tools_previewer = new MenuItem.with_label 
											(_("Animation Previewer..."));
		tools_palette = new MenuItem.with_label  
											(_("Edit Default Palette..."));

		tools_menu.append (tools_previewer);
		tools_menu.append (tools_palette);

		tools_menu_button = new MenuItem.with_mnemonic (_("_Tools"));
		tools_menu_button.set_submenu (tools_menu);
		append (tools_menu_button);	

		/* Help Menu */
		var help_menu = new Menu ();
		help_about = new MenuItem.with_label (_("About"));

		help_menu.append(help_about);
        
		help_menu_button = new MenuItem.with_mnemonic (_("_Help"));
		help_menu_button.set_submenu (help_menu);
		append (help_menu_button);		
	}
}
